<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Blade Single Test</title>
<script type="text/javascript" src="/shared/scripts/testcase.js"></script>
<script type="text/javascript" src="/shared/scripts/utils.js"></script>
<script type="text/javascript" src="/shared/scripts/runner.js"></script>
<script type="text/javascript">
if (window.addEventListener) {
	window.addEventListener("load", build_menu, false);
} else if (window.attachEvent) {
	window.attachEvent("onload", build_menu);
} else {
	window.onload = build_menu;
}

function write_out(data) {
	var output = document.getElementById("output");
	var txt_node = document.createTextNode(data);
	var br_ele = document.createElement("br");
	output.appendChild(txt_node);
	output.appendChild(br_ele);
}

function build_menu() {
	var ifr = document.getElementById("ifr");
	var jsb = new JsBlade(ifr, write_out);
	jsb.getCasesOfType("all");
	var select_menu = document.getElementById("test_cases");
	for (var i = 0; i < jsb.cases.length; ++i) {
		var element = create_option(jsb.cases[i]);
		select_menu.appendChild(element);
	}
}

function create_option(data) {
	var optn = document.createElement("option");
	var optn_txt = document.createTextNode(data);
	try {
		optn.text = data;
		optn.value = data;
		optn.innerHTML = data;
		
	} catch(e) {
		optn.setAttribute("value", data);
		optn.appendChild(optn_txt);
	}
	return optn;
}

function start() {
	var ifr = document.getElementById("ifr");
	var output = document.getElementById("output");
	var test_case = document.getElementById("test_cases").value;
	var jsblade = new JsBlade(ifr, write_out);
	write_out("Our client_id is: " + jsblade.client_id);
	if (test_case == "") {
		write_out("no test case selected...?");
	}
	write_out("Running single test of: " + test_case)
	jsblade.runSingleTest(test_case);
}


</script>
</head>
	<body>
		<div>Choose a test case: 
			<select id="test_cases">
				<option value="">Test case...</option>
			</select>
			<br>
			and click: 
			<button onclick="start()">start</button>
			<br>
			<iframe src="" id="ifr"></iframe>
			<p id="output">
			</p>
		</div>
	</body>
</html>